package com.example.myandroidapp1;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.preference.PreferenceManager;

public class SplashActivity extends Activity{
	
	MediaPlayer ourSound;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splash);
		ourSound = MediaPlayer.create(SplashActivity.this, R.raw.beep_30);
		
		SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
		boolean soundOn = sharedPreferences.getBoolean("sound", false);
		if(soundOn){
			ourSound.start();
		}
		
		Thread t = new Thread(){
			
			@Override
			public void run() {
				try {
					Thread.sleep(500);
					Intent mainActivity = new Intent("com.example.myandroidapp1.MENU");
					startActivity(mainActivity);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
			
		};
		
		t.start();
	}
	
	@Override
	protected void onPause() {
		super.onPause();
		ourSound.release();
		finish();
	}
}
